package com.ruoyi.buss.grid.zysc.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.buss.grid.zysc.domain.DataWgZyscSurvey;
import com.ruoyi.buss.grid.zysc.service.IDataWgZyscSurveyService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 专业市场概况Controller
 * 
 * @author sxy
 * @date 2021-07-16
 */
@RestController
@RequestMapping("/zyscsurvey")
public class DataWgZyscSurveyController extends BaseController
{
    @Autowired
    private IDataWgZyscSurveyService dataWgZyscSurveyService;

    /**
     * 查询专业市场概况列表
     */
    @PreAuthorize(hasPermi = "buss:zyscsurvey:list")
    @GetMapping("/list")
    public TableDataInfo list(DataWgZyscSurvey dataWgZyscSurvey)
    {
        startPage();
        List<DataWgZyscSurvey> list = dataWgZyscSurveyService.selectDataWgZyscSurveyList(dataWgZyscSurvey);
        return getDataTable(list);
    }

    /**
     * 导出专业市场概况列表
     */
    @PreAuthorize(hasPermi = "buss:zyscsurvey:export")
    @Log(title = "专业市场概况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataWgZyscSurvey dataWgZyscSurvey) throws IOException
    {
        List<DataWgZyscSurvey> list = dataWgZyscSurveyService.selectDataWgZyscSurveyList(dataWgZyscSurvey);
        ExcelUtil<DataWgZyscSurvey> util = new ExcelUtil<DataWgZyscSurvey>(DataWgZyscSurvey.class);
        util.exportExcel(response, list, "专业市场概况数据");
    }

    /**
     * 获取专业市场概况详细信息
     */
    @PreAuthorize(hasPermi = "buss:zyscsurvey:query")
    @GetMapping(value = "/{marketId}")
    public AjaxResult getInfo(@PathVariable("marketId") String marketId)
    {
        return AjaxResult.success(dataWgZyscSurveyService.selectDataWgZyscSurveyById(marketId));
    }

    /**
     * 新增专业市场概况
     */
    @PreAuthorize(hasPermi = "buss:zyscsurvey:add")
    @Log(title = "专业市场概况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataWgZyscSurvey dataWgZyscSurvey)
    {
        return toAjax(dataWgZyscSurveyService.insertDataWgZyscSurvey(dataWgZyscSurvey));
    }

    /**
     * 修改专业市场概况
     */
    @PreAuthorize(hasPermi = "buss:zyscsurvey:edit")
    @Log(title = "专业市场概况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataWgZyscSurvey dataWgZyscSurvey)
    {
        return toAjax(dataWgZyscSurveyService.updateDataWgZyscSurvey(dataWgZyscSurvey));
    }

    /**
     * 删除专业市场概况
     */
    @PreAuthorize(hasPermi = "buss:zyscsurvey:remove")
    @Log(title = "专业市场概况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{marketIds}")
    public AjaxResult remove(@PathVariable String[] marketIds)
    {
        return toAjax(dataWgZyscSurveyService.deleteDataWgZyscSurveyByIds(marketIds));
    }
}
